<script setup lang="ts">
const emit = defineEmits(['close-modal', 'confirm-modal'])
const closeModal = () => {
    emit('closeModal')
}

const confirmModal = () => {
    emit('confirmModal')
}

const props = defineProps({
    text: {
        type: String,
        default: ''
    }
})
</script>

<template>
    <div class="prompt">
        <div class="prompt-content">
            <div class="prompt-top">提示
                <button class="close" @click="closeModal">&times;</button>
            </div>
            <div class="prompt-body">
                {{ text }}
            </div>
            <div class="prompt-bottom">
                <button class="cancel" @click="closeModal">取消</button>
                <button class="confirm" @click="confirmModal">确定</button>
            </div>
        </div>
    </div>
</template>

<style scoped lang="scss">
.prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;

    .prompt-content {
        background-color: #fff;
        border-radius: 10px;
        height: 250px;
        width: 300px;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
        animation: slideDown 0.1s ease-out;

        .prompt-top {
            text-align: center;
            height: 50px;
            border-top-left-radius: 10px;
            border-top-right-radius: 10px;
            background: #408cff;
            color: #fff;
            padding: 15px 0;

            .close {
                padding: 0;
                padding-right: 10px;
                margin-top: -7px;
                background: transparent;
                border: 0;
                float: right;
                font-size: 21px;
                color: #fff;
                line-height: 1;
                font-weight: bold;
                cursor: pointer;
            }
        }

        .prompt-body {
            display: flex;
            align-items: center;
            flex-direction: column;
            text-align: center;
            padding: 40px 20px;
            color: #333;
            font-size: 14px;

        }

        .prompt-bottom {
            display: flex;
            justify-content: center;
            background-color: #fff;

            .cancel {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 80px;
                height: 32px;
                background-color: #fff;
                color: #999;
                border: 1px solid #999;
            }

            .confirm {
                display: flex;
                align-items: center;
                justify-content: center;
                width: 80px;
                height: 32px;
                background-color: #408cff;
                color: #fff;
                border: 1px solid #999;
                margin-left: 20px;
            }
        }
    }
}

// 动画
@keyframes slideDown {
    from {
        transform: translateY(-50%);
    }

    to {
        transform: translateY(0);
    }
}
</style>